<template>
  <div class="page-wrapper">
    <el-pagination
      class="is-background"
      :current-page="currentPage"
      layout="total, sizes, prev, pager, next, jumper"
      :page-size="pageSize"
      :page-sizes="[10, 20, 30, 40]"
      :total="total"
      @current-change="changeCurrentPage"
      @size-change="changePagesize"
    />
  </div>
</template>

<script type="text/ecmascript-6">
  export default {
    name: 'PageContainer',
    props: {
      listObj: {
        type: Object,
        default() {
          return {}
        }
      }
    },
    computed: {
      total() {
        return this.listObj.data ? this.listObj.data.total : 0
      },
      currentPage() {
        return this.listObj.data ? this.listObj.data.current_page : 1
      },
      pageSize() {
        return this.listObj.data ? this.listObj.data.per_page : 1
      }
    },
    methods: {
      changeCurrentPage(val) {
        this.$emit('changeCurrentPage', val)
      },
      changePagesize(val) {
        this.$emit('changePagesize', val)
      }
    }
  }
</script>

<style lang="scss" scoped>
  .page-wrapper {
    margin-top: 15px;
  }
</style>
